<template>
  <view></view>
</template>

<script>
import {mapGetters, mapActions} from 'vuex'
import {commonApi} from "@/api";

export default {
  name: 'ADInterstitial',
  data() {
    return {}
  },
  computed: {
    ...mapGetters(['mine', 'haveVIP', 'settings', 'needShowAD', 'chapingAdId']),
  },
  methods: {
    tryOpen() {
      // #ifndef APP-PLUS
      return
      // #endif

      return;

      if (!this.needShowAD) {
        console.log('不弹广告')
        return
      }
      uni.showLoading({
        mask: true
      })
      if (uni.canIUse('createInterstitialAd')) {
        const interstitialAd = uni.createInterstitialAd({
          adpid: this.chapingAdId,
        });
        interstitialAd.onLoad(() => {
          console.log("插屏 广告加载成功");
          uni.hideLoading()
          interstitialAd.show().then(() => {
            console.log('show then')
          });
        })

        interstitialAd.onClose(() => {
          commonApi.uploadAD(2)
          console.log("插屏 广告关闭");
          uni.hideLoading()
          uni.showToast({
            icon: 'none',
            duration: 8000,
            position: "bottom",
            title: '温馨提示：开通VIP获取免广告等更多权益'
          })
        });
        interstitialAd.onError((err) => {
          console.log("插屏 广告加载失败");
          uni.hideLoading()
        });
      }
    },
    toVIP() {
      uni.navigateTo({
        url: '/pages/vip/vip'
      })
    }
  }
}
</script>

<style scoped lang='scss'>
.MsgDialog-container {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 546rpx;
  background-color: #fff;
  border-radius: 50rpx;

  .aabg {
    width: 546rpx;
    background-image: url("http://down.qwdata.vip/app_icon/1706166602691");
    height: 230rpx;
    background-position: center;
    background-size: contain;
  }

  .title {
    margin-top: 42rpx;
    text-align: center;
    color: #000;
    font-size: 19px;
    font-weight: bold;
  }

  .btns-container {
    display: flex;
    margin-top: 48rpx;
    flex-direction: column;
    margin-bottom: 58rpx;
  }

  .double-btn {
    height: 100rpx;
    margin-left: 62rpx;
    margin-right: 62rpx;
    background-color: #1B80FD;
    border-radius: 60rpx;
    display: flex;
    font-size: 15px;
    color: #fff;
    justify-content: center;
    align-items: center;
    margin-top: 32rpx;
    font-weight: bold;

    &:first-child {
      margin-top: 0;
    }

    &.primary {
      background-color: #E3C898;
      color: #0B0B0B;
    }
  }

  .close-btn {
    position: absolute;
    right: 0;
    top: 0;
    padding: 40rpx;

    .icon {
      width: 24rpx;
      height: 24rpx;
    }
  }
}
</style>
